package com.aaa.servlet;

import com.aaa.dao.UserInfoDao;
import com.aaa.dao.impl.UserInfoDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/7/29 15:59
 * @description：我这辈子第一个servlet
 * @modified By：
 * @version: 1
 */
public class MyServlet  extends HttpServlet {
    UserInfoDao userInfoDao = new UserInfoDaoImpl();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = req.getParameter("name");
        String password = req.getParameter("password");
        Map map = new HashMap<>();
        map.put("username",name);
        map.put("password",password);
        boolean checkUser = userInfoDao.checkUser(map);
        if(checkUser){
                //去登录成功页面
            req.getRequestDispatcher("success.jsp").forward(req,resp);
        }else
        {
                //去登录失败页面
            req.getRequestDispatcher("fail.jsp").forward(req,resp);
        }
     /*   System.out.println("我的service方法开始执行了");
        System.out.println("请求传入的name参数:"+name+" || password参数："+password);*/
    }
}
